<template>
  <el-dialog  :visible.sync="isShow" center class="order-info" :before-close="handleClose">
    <!-- <h1 class="order-info_title">{{orderData.order_number}}</h1> -->
    <div class="btns tc">
      <el-button type="danger" @click="orderRescind" :disabled="orderData.reason != null || sumDate > 10" v-if="$store.state.user.is_teacher != 2" v-no-more-click:3000>撤案申请</el-button>
			<el-button type="danger" v-if="orderData.status == '案件内审中' && $store.state.user.is_teacher != 2" @click="resetFile">撤回内审文件</el-button>
			<el-button type="primary" v-if='orderData.is_distribution == 3 && !orderData.order_pay' @click="goPay">去支付</el-button>
      <el-button v-if="orderData.status == '文件格式审核中' && $store.state.user.is_teacher != 2"  type="danger" @click.stop="withdrawCompleteFile(orderData)" v-no-more-click:3000>撤回上报文件</el-button>
			<el-button v-if="$store.state.user.is_teacher == 1 && orderData.status == '代理人撰写中'" :disabled='canAllocationOrder' type="danger" @click.stop="distributeOrder(orderData)" v-no-more-click:3000>分配订单</el-button>
      <el-button
        v-if="$store.state.user.is_teacher == 1 && (orderData.status == '代理人撰写中' || orderData.status == '案件修改中') && (orderData.student_review_file)"
        type="primary"
        @click="auditorOrder(orderData)"
        v-no-more-click:3000>
        审核
    </el-button>
    </div>
    <el-row >
      {{opDateMax}}
      <el-steps :active="opDateMax" class="steps" process-status='success' finish-status="success" align-center>
        <el-step v-for="(item,index) in steps_text"   :title="item" description="" :key="index"></el-step>
      </el-steps>
    </el-row>
    <div class="fold">
      <div class="fold_header clearfloat" @click="processProgress = !processProgress" >
        <span class="fl">流程进度</span>
        <span class=" fr">
          <i 
            :class=" processProgress ? 'el-icon-arrow-down' : 'el-icon-arrow-up'">
          </i>
        </span>
      </div>
      <el-collapse-transition>
        <div v-show="processProgress">
          <el-timeline v-for="(item,index) in orderData.statuss" :key="index">
            <el-timeline-item  placement="top" :timestamp="item.pivot.created_at">
              <template slot="dot">
                <span class="time" v-if="index*1<orderData.statuss.length-1">耗时：{{intervalTime(orderData.statuss[index*1+1].pivot.created_at,orderData.statuss[index*1].pivot.created_at)}}</span>
                <div class="el-timeline-item__node">
                  
                </div>
              </template>
              <h4  v-if="!(/^(2|4|5|28|29|13|15|18)$/.test(item.id))">{{item.name}}</h4>
              
              <div v-if="item.id == 1">
                发明人：<span class="font_success">{{ orderData.liaisons }}</span>  提交
              </div>

              <!-- 上传内审文件 -->
              <div v-if="(item.id == 2 || item.id == 18) " class="clearfloat">
                <div class="fl">
                  <p class="title" v-if="item.id != 18 && orderData.status != '代理人撰写中'">{{item.name}}</p>
                  <p v-if="item.id == 2">
                    代理人：<span class="font_success">{{ orderData.agent | agentNumAddName }}</span> 接单
                  </p>
                  <div class="file-list mt10" v-if="orderData.status == '代理人撰写中' && index == 0">
                    <div class="file-list_item"  v-for="(item,fileIndex) in fileListV" :key="fileIndex" @mouseenter='fileListShowClose(item)' @mouseleave='fileListHidClose(item)'>
                      <el-tooltip :content="item.name" placement="top">
                        <span class="file-list_item_name">{{item.name}}</span>
                      </el-tooltip>
                      <span>{{item.time}}</span>
                      <span class="fr ml20" v-if='item.close'>
                        <i class="el-icon-close" @click="closeFileList(item,fileIndex)"></i>
                      </span>
                    </div>
                  </div>
                </div>
                <el-upload 
                  v-if="orderData.status == '代理人撰写中' && index == 0 && !student_upload && teacher_upload"
                  class="fr" 
                  ref="upload" 
                  :auto-upload="false" 
                  :on-change="auditChange" 
                  :action="baseUrl + '/api/order/'+ orderData.id +'/send/file'"
                  :file-list="fileList" 
                  :http-request="uploadSectionFile" 
                  :on-remove="handleRemove" 
                  :show-file-list='false'
                  multiple 
                  :limit="5">
                  <el-button slot="trigger" size="small" type="primary">选择文件</el-button>
                  <el-popover
                    placement="right"
                    title="内审文件格式"
                    width="520"
                    popper-class="tips"
                    trigger="hover">
                    <div class="tips_1">请直接上传已完成的word文档,单个主体文件,无需分解,仅供内容审查</div>
                    <div class="tips_2">* 如果多报或者分案或返修等,请分别上传word文件</div>
                    <div class="tips_2">* 多报文件命名格式：订单编号-代理人姓名-案件名称-案件类型.docx</div>
                    <div class="tips_2">* 分案文件格式为：订单编号-序号(数字)-代理人姓名-案件名称-案件类型.docx</div>
                    <!-- <div>例：测试代理人-测试案件名称-发明专利.docx</div> -->
                    <i class='el-icon-info orange ml10' slot="reference"></i>
                  </el-popover>
                  <el-button v-no-more-click:8000 style="margin-left: 10px;" size="small" type="success" :loading="fileBtnLoading" @click="submitUpload(false)">确认发送</el-button>
                </el-upload>      
              </div>

              <div v-if="item.id == 3" >
                代理人：<span class="font_success">{{ orderData.agent | agentNumAddName}}</span> 提交审核文件
              </div>
              <!-- 上传定稿文件 -->
              <div v-if="item.id == 4" class="clearfloat">
                <div class="fl">
                  <p class="title">{{item.name}}</p>
                  <p v-if='item.id == 4' >
                    审核员：<span class="font_success">{{orderData.auditor_name}}</span> 审核
                  </p>
                  <div class="file-list mt10">
                    <!-- 自提传上报文件 -->
                    <template v-if="orderData.is_distribution == 3">
                      <div class="file-list mt10" v-if="orderData.status == '上报文件上传中' && index == 0">
                        <div v-if='fileListV.length'>
                          <span class="sameDay font_success">是否需要与其他案件同日提交，如需要，请勾选</span>
                          <el-checkbox @change='sameDayCheckChange' v-model="sameDay.isSameDay">{{sameDay.isSameDay ? '是' : '否'}}</el-checkbox>
                          <el-popover
                            v-if='sameDay.isSameDay'
                            placement="right"
                            width="300"
                            popper-class="sameDayList"
                            trigger="click">
                            <el-input v-model="orderNumberQuery" @input='queryChanged' placeholder="请输入编号查询"></el-input>
                            <div v-for="(item, index) in orderNumbers" :key="index" class="numberList">
                              <span class="number">{{item.value}}</span>
                              <el-checkbox v-model="item.isSelect"></el-checkbox>
                            </div>
                            <el-button slot="reference" type="primary" icon="el-icon-plus" size="small" class='ml10'></el-button>
                          </el-popover>
                          <div  v-for="(item, index) in orderNumbers" :key="index" class="numbers">
                            <div v-if="item.isSelect" class="number numberItem" @mouseenter='fileListShowClose(item)' @mouseleave='fileListHidClose(item)'>
                              <span >{{item.value}}</span>
                              <span class="fr" v-if='item.close'>
                                <i class="el-icon-close" @click="closeOrderNumber(item,index)"></i>
                              </span>
                            </div>
                          </div>
                      
                        </div>
                        <template >
                          <div class="file-list_item"  v-for="(item,index) in fileListV" :key="index" @mouseenter='fileListShowClose(item)' @mouseleave='fileListHidClose(item)'>
                            <el-tooltip :content="item.name" placement="top">
                              <span class="file-list_item_name">{{item.name}}</span>
                            </el-tooltip>
                            <span >{{item.time}}</span>
                            <div class='fr ml20 closeIcon' v-if='item.close'>
                              <i class="el-icon-close" @click="closeFileList(item,index)"></i>
                            </div>
                          </div>
                        </template>
                      </div>
                    </template>
                    <!-- 正常案件传定稿文件 -->
                    <template v-else>
                      <div  class="file-list_item"  v-for="(item,fileIndex) in fileListV" :key="fileIndex" @mouseenter='fileListShowClose(item)' @mouseleave='fileListHidClose(item)' >
                        <template v-if="orderData.status == '定稿文件发送中' && index == 0  && $store.state.user.is_teacher != 2">
                          <el-tooltip :content="item.name" placement="top">
                            <span class="file-list_item_name">{{item.name}}</span>
                          </el-tooltip>
                          <span>{{item.time}}</span>
                          <span class="fr ml20" v-if='item.close'>
                            <i class="el-icon-close" @click="closeFileList(item,fileIndex)"></i>
                          </span>
                        </template>        
                      </div>
                    </template>
                  </div>
                </div>
                <template v-if="orderData.is_distribution == 3">
                  <el-upload
                    v-if="orderData.status == '上报文件上传中' && index == 0  && $store.state.user.is_teacher != 2"
                    ref="upload"
                    class="fr" 
                    multiple
                    :auto-upload="true"
                    :on-change="handleChangeByok"
                    :action="baseUrl + 'api/order/'+ orderData.id +'/upload/confirm/file'"
                    :file-list="fileList"
                    :on-remove="handleRemove"
                    :http-request="uploadSectionFile"
                    :show-file-list='false'
                    :limit="5">
                    <el-button v-no-more-click:8000 slot="trigger" size="small" type="primary">选择文件</el-button>
                    <el-popover
                      placement="right"
                      title="上传上报文件"
                      width="500"
                      popper-class="tips"
                      trigger="hover">
                      <p style="color:red">* 文件格式：编号-姓名(发明人)-案件名称-专利类型.rar/zip 后缀名为.rar/.zip</p>
                      <p style="color:red">* 专利类型必须为：发明专利，外观设计，实用新型。</p>
                      <i class='el-icon-info orange ml10' slot="reference"></i>
                    </el-popover>
                    <el-button v-no-more-click:8000 style="margin-left: 10px;" size="small" type="success" @click="uploadSectionFileByok">确认上传</el-button>
                  </el-upload>
                </template>
                <template v-else>
                  <el-upload 
                    v-if="orderData.status == '定稿文件发送中' && index == 0 && $store.state.user.is_teacher != 2"
                    class="fr" 
                    ref="upload" 
                    :auto-upload="false" 
                    :on-change="finalizeChange" 
                    :action="baseUrl + '/api/order/'+ orderData.id +'/send/file'"
                    :file-list="fileList" 
                    :http-request="uploadSectionFile" 
                    :on-remove="handleRemove" 
                    :show-file-list='false'
                    multiple 
                    :limit="5">
                    <el-button slot="trigger" size="small" type="primary">选择文件</el-button>
                    <el-popover
                      placement="right"
                      title="定稿文件发送中"
                      width="500"
                      popper-class="tips"
                      trigger="hover">
                      <p>* 文件为文档格式：订单编号-代理人姓名-案件名称-案件类型.docx</p>
                      <i class='el-icon-info orange ml10' slot="reference"></i>
                    </el-popover>
                    <el-button v-no-more-click:8000 style="margin-left: 10px;" size="small" type="success" :loading="fileBtnLoading" @click="submitUploadDG">确认发送</el-button>
                  </el-upload>
                </template>
                
              </div>
              <!-- 上传修改文件 -->
              <div v-if="item.id == 5 || item.id == 15 || item.id == 18" class="clearfloat">
                <div class="fl">
                  <p class="title">{{item.name}}</p>
                  <p v-if="item.id == 5">
                    审核员：<span class="font_success">{{orderData.auditor_name}}</span> 审核
                  </p>
                  <div class="file-list mt10" v-if="orderData.status == '案件修改中' && index == 0 && (item.id == 5 || item.id == 18 || (item.id == 15 && $store.state.user.is_teacher != 2))">
                    <div class="file-list_item"  v-for="(item,fileIndex) in fileListV" :key="fileIndex" @mouseenter='fileListShowClose(item)' @mouseleave='fileListHidClose(item)'>
                      <el-tooltip :content="item.name" placement="top">
                        <span class="file-list_item_name">{{item.name}}</span>
                      </el-tooltip>
                      <span >{{item.time}}</span>
                      <span class="fr ml20" v-if='item.close'>
                        <i class="el-icon-close" @click="closeFileList(item,fileIndex)"></i>
                      </span>
                    </div>
                  </div>
                </div>
                <el-upload 
                  v-if="orderData.status == '案件修改中' && index == 0  && (item.id == 5 ||item.id == 18 || (item.id == 15 && $store.state.user.is_teacher != 2))"
                  class="fr" 
                  ref="upload" 
                  :auto-upload="false" 
                  :on-change="auditChange" 
                  :action="baseUrl + '/api/order/'+ orderData.id +'/send/file'"
                  :file-list="fileList" 
                  :http-request="uploadSectionFile" 
                  :on-remove="handleRemove" 
                  :show-file-list='false'
                  multiple 
                  :limit="5">
                  <el-button slot="trigger" size="small" type="primary">选择文件</el-button>
                  <el-popover
                    placement="right"
                    title="内审文件格式"
                    width="500"
                    popper-class="tips"
                    trigger="hover">
                    <div class="tips_1">请直接上传已完成的word文档,单个主体文件,无需分解,仅供内容 审查</div>
                    <div class="tips_2">* 如果多报或者分案或返修等,请分别上传word文件</div>
                    <div class="tips_2">* 多报返修文件格式为：订单编号-代理人姓名-案件名称-案件类型-R(数字).docx</div>
                    <div class="tips_2">* 分案返修文件格式为：订单编号-序号(数字)-代理人姓名-案件名称-案件类型-R(数字).docx</div>
                    <i class='el-icon-info orange ml10' slot="reference"></i>
                  </el-popover>
                  <el-button v-no-more-click:8000 style="margin-left: 10px;" size="small" type="success" :loading="fileBtnLoading" @click="submitUpload(false)">确认发送</el-button>
                </el-upload>
              </div>

              <div v-if="item.id == 7"  class="clearfloat">
                代理人：<span class="font_success"> {{ orderData.agent | agentNumAddName}}</span> 提交
              </div>
              <!-- 上传上报文件 -->
              <div v-if="item.id == 13  || item.id == 28 || item.id == 29"  class="clearfloat">
                <div class="fl">
                  <p class="title">{{item.name}}</p>
                  <p>
                    联络人：<span class="fontgreen">{{orderData.liaisons}}</span> 提交
                  </p>
                  <div class="file-list mt10" v-if="orderData.status == '上报文件上传中' && index == 0">
                    <div v-if='fileListV.length'>
                      <span class="sameDay font_success">是否需要与其他案件同日提交，如需要，请勾选</span>
                      <el-checkbox @change='sameDayCheckChange' v-model="sameDay.isSameDay">{{sameDay.isSameDay ? '是' : '否'}}</el-checkbox>

                      <el-popover
                        v-if='sameDay.isSameDay'
                        placement="right"
                        width="300"
                        popper-class="sameDayList"
                        trigger="click">
                        <el-input v-model="orderNumberQuery" @input='queryChanged' placeholder="请输入编号查询"></el-input>
                        <div v-for="(item, numberIndex) in orderNumbers" :key="numberIndex" class="numberList">
                          <span class="number">{{item.value}}</span>
                          <el-checkbox v-model="item.isSelect"></el-checkbox>
                        </div>
                        <el-button slot="reference" type="primary" icon="el-icon-plus" size="small" class='ml10'></el-button>
                      </el-popover>

                      <div  v-for="(item, orderIndex) in orderNumbers" :key="orderIndex" class="numbers">
                        <div v-if="item.isSelect" class="number numberItem" @mouseenter='fileListShowClose(item)' @mouseleave='fileListHidClose(item)'>
                          <span >{{item.value}}</span>
                          <span class="fr" v-if='item.close'>
                            <i class="el-icon-close" @click="closeOrderNumber(item,orderIndex)"></i>
                          </span>
                        </div>
                      </div>
                      <br />
                      <span class="font_success" v-if="orderData.is_distribution != 3">权利要求数超过10项的为超项数，小于等于10，超项数为0。勾选填写超项数。</span>
                    </div>
                    <template >
                      <div class="file-list_item"  v-for="(item,fileIndex) in fileListV" :key="fileIndex" @mouseenter='fileListShowClose(item)' @mouseleave='fileListHidClose(item)'>
                        <el-tooltip :content="item.name" placement="top">
                          <span class="file-list_item_name">{{item.name}}</span>
                        </el-tooltip>
                        <span>{{item.time}}</span>
                        <div class="file-list_item_checkbox" v-if="orderData.is_distribution != 3">
                          <el-checkbox v-model="item.isBeyond">{{item.isBeyond ? '是' : '否'}}</el-checkbox>
                        </div>
                        <div class="file-list_item_input" v-if="orderData.is_distribution != 3">
                          <el-input v-if="item.isBeyond" v-model.number="item.claimValue" size="small"></el-input>
                        </div>

                        <div class='fr ml20 closeIcon' v-if='item.close'>
                          <i class="el-icon-close" @click="closeFileList(item,fileIndex)"></i>
                        </div>
                      </div>
                    </template>
                  </div>
                </div>
                <el-upload
                  v-if="orderData.status == '上报文件上传中' && index == 0 && $store.state.user.is_teacher != 2"
                  ref="upload"
                  class="fr" 
                  multiple
                  :auto-upload="true"
                  :on-change="handleChangeByok"
                  :action="baseUrl + 'api/order/'+ orderData.id +'/upload/confirm/file'"
                  :file-list="fileList"
                  :on-remove="handleRemove"
                  :http-request="uploadSectionFile"
                  :show-file-list='false'
                  :limit="5">
                  <el-button v-no-more-click:8000 slot="trigger" size="small" type="primary">选择文件</el-button>
                  <el-popover
                    placement="right"
                    title="上传上报文件"
                    width="500"
                    popper-class="tips"
                    trigger="hover">
                    <p style="color:red">* 文件格式：编号-姓名(发明人)-案件名称-专利类型.rar/zip 后缀名为.rar/.zip</p>
                    <p style="color:red">* 专利类型必须为：发明专利，外观设计，实用新型。</p>
                    <i class='el-icon-info orange ml10' slot="reference"></i>
                  </el-popover>
                  <el-button v-no-more-click:8000 style="margin-left: 10px;" size="small" type="success" @click="uploadSectionFileByok">确认上传</el-button>
                </el-upload>
              </div>
              
            </el-timeline-item>
          </el-timeline>
        </div>
      </el-collapse-transition>
    </div>
    <div class="fold">
      <div class="fold_header clearfloat" @click="orderInfoShow = !orderInfoShow">
        <span class="fl">订单详情</span>
        <span class=" fr">
          <i 
            :class=" orderInfoShow ? 'el-icon-arrow-down' : 'el-icon-arrow-up'">
          </i>
        </span>
      </div>
      <el-collapse-transition>
        <div v-show="orderInfoShow">
          <el-form :model="orderData"  class='form'>
            <el-row type="flex">
              <el-col :span="24">
                <el-form-item  label="专利名称:">
                  <span>{{orderData.patent_name}}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="12">
                <el-form-item  label="订单编号:">
                  <span>{{orderData.order_number}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item  label="专利类型:">
                  <span >{{orderData.type}}</span>
                </el-form-item>
              </el-col>
            </el-row>         
            <el-row type="flex">
              <el-col :span="12">
                <el-form-item  label="订单状态:">
                  <span :class='orderData.status == "已撤案" ? "font_danger" : "font_success"'>{{orderData.status}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item  label="联络人:">
                  <span>{{orderData.liaisons}}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="12">
                <el-form-item  label="联络人邮箱：">
                  <span >{{orderData.liaisons_email}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item  label="联络人电话：">
                  <span>{{orderData.liaisons_tel}}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="12">
                <el-form-item  label="代理人：">
                  <span 
                    v-if="orderData.agent"
                    :class="orderData.agent.type =='离职'?'font_danger':'font_success'">{{orderData.agent | agentNumAddName}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item  label="专属顾问：">
                  <span class="font_success" v-if='orderData.process'>{{orderData.process | processNumber}}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="24">
                <el-form-item  label="技术问题：">
                  <span >{{orderData.problem}}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="24">
                <el-form-item  label="技术方案：">
                  <span >{{orderData.plan}}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="24">
                <el-form-item  label="项目优势：">
                  <span >{{orderData.advantage}}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="24">
                <el-form-item  label="备注：">
                  <span >{{orderData.remarks}}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="12">
                <el-form-item  label="附图：">
                  <div v-if="orderData.img != '' || orderData.img != null" class="preview-img-wrap">
                    <pre-img
                      :smallImg="orderData.imgList"
                      :bigImg="orderData.imgList2"
                      class="pre-img">
                    </pre-img>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item  label="附件：">
                  <div  v-if="orderData.file != '' || orderData.file != null" style="height: 40px;-webkit-display:flex;
                    display:flex;
                    font-size: 20px
                    -webkit-align-items:center;
                    align-items:center;">
                    <a v-for="item in orderData.fileArr" :key="item.id" :href="baseUrl + '/api/download?path='  + item.file +'/'+ item.path"
                    :download="item.path" :title="item.path" class="el-icon-tickets file_sh"></a>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
            <!-- v-if='student_upload' -->
            <el-row type="flex" >
              <el-col :span="24">
                <el-form-item label="导师审核文件：">
                  <div  v-if="orderData.student_review_file != '' && orderData.student_review_file != null" style="height: 40px;-webkit-display:flex;
                    font-size: 20px
                    display:flex;
                    -webkit-align-items:center;
                    align-items:center;">
                    <a v-for="item in orderData.studentFile" :key="item.id" :href="baseUrl + '/api/download?path='  + item.file +'/'+ item.path"
                    :download="item.path" :title="item.path" class="el-icon-tickets file_sh"></a>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" v-if="orderData.review_file != '' && orderData.review_file != null" >
              <el-col :span="24">
                <el-form-item label="内容审查文件：">
                  <div  style="height: 40px;-webkit-display:flex;
                    font-size: 20px
                    display:flex;
                    -webkit-align-items:center;
                    align-items:center;">
                    <a v-for="item in orderData.reviewfileArr" :key="item.id" :href="baseUrl + '/api/download?path='  + item.file +'/'+ item.path"
                    :download="item.path" :title="item.path" class="el-icon-tickets file_sh"></a>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" v-if="orderData.confirm_file != '' && orderData.confirm_file != null" >
              <el-col :span="24">
                <el-form-item label="定稿文件：">
                  <div  style="height: 40px;-webkit-display:flex;
                    font-size: 20px
                    display:flex;
                    -webkit-align-items:center;
                    align-items:center;">
                    <a v-for="item in orderData.confimFiles" :key="item.id" :href="baseUrl + '/api/download?path='  + item.file +'/'+ item.path"
                    :download="item.path" :title="item.path" class="el-icon-tickets file_sh"></a>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
            <template v-if="orderData.status == '上报文件上传中'">
              <el-row v-if="orderData.grades" type="flex">
                <el-col :span="12">
                  <el-form-item label="服务态度：" >
                    <el-rate
                      disabled
                      class="agetn-rate"
                      show-score
                      allow-half
                      :value="Number(orderData.grades.attitude)">
                    </el-rate>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="撰写质量：">
                    <el-rate
                      disabled
                      show-score
                      class="agetn-rate"
                      allow-half
                      :value="Number(orderData.grades.quelity)">
                    </el-rate>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row v-if="orderData.grades" type="flex">
                <el-col :span="12">
                  <el-form-item label="撰写耗时："  class="flex-form">
                    <el-rate
                      disabled
                      show-score
                      allow-half
                      class="agetn-rate"
                      :value="Number(orderData.grades.take_time)">
                    </el-rate>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="用户评价：" >
                    {{orderData.grades.remark}}
                  </el-form-item>
                </el-col>
              </el-row>
  
            </template>
          </el-form>
        </div>
      </el-collapse-transition>
    </div>
    <el-dialog title="请输入您的工作邮件密码" center :visible.sync="isShowEmailPwd" :before-close="handleCloseEmail" append-to-body>
      <el-input type="password" class="pwd_inp" placeholder="请输入发送邮件密码" v-model="emailPwd"></el-input>
      <el-button v-no-more-click:8000 type="primary" @click="handleCloseEmail">取消</el-button>
      <el-button v-no-more-click:8000 type="success" @click="emailPwdFn">确认</el-button>
    </el-dialog>

    <!-- 订单撤销 -->
		<order-rescind ref="order-rescind" @rescind="rescind"></order-rescind>

    <!-- 代理人撤回上报文件 -->
		<withdrawCompleteFile ref='withdrawCompleteFile' @refresh='refresh'></withdrawCompleteFile>

		<!-- 导师分配代理人 -->
		<distributeOrder ref='distributeOrder' @refresh='refresh'></distributeOrder>

    <!-- 导师审核徒弟撰写文件  -->
    <studentOrder ref="studentOrder" @refresh='refresh'/>

    <file-recind ref="file-recind" @refresh="refresh"></file-recind>
  </el-dialog>
</template>

<script>
import preImg from '~/components/pre-img'
import {intervalTime} from '~/util'
import aes from "~/util/aes.js";
import moment from 'moment'
import axios from "axios";
import orderRescind from '~/pages/admin/order/dialogPage/order-rescind'
import withdrawCompleteFile from '~/pages/admin/order/dialogPage/withdrawCompleteFile'
import distributeOrder from './distributeOrder'
import studentOrder from './studentOrder'
import fileRecind from './file-recind'
export default {
  components: {
    preImg,
    orderRescind,
    withdrawCompleteFile,
    distributeOrder,
    studentOrder,
    fileRecind,
    
  },
  data () {
    return {
      isShow: false,
      isShowEmailPwd: false,
      orderData: {
      },
      opDateMax: 1, //状态里最大的id是多少
      order_id: null,
      baseUrl: global.baseurl,
      steps_text: ['提交申请', '代理人接单', '案件撰写', '案件质控', '发送定稿文件', '发明人定稿', '案件上传', '递交国知局'],
      // steps_text: this.stepsText,
      step_status: 'success',
      processProgress: false,
      orderInfoShow: false,
      fileList: [],
      fileListV:[],
      emailPwd: '',
      fileBtnLoading: false,
      sameDay: {
        isSameDay: false,
        same_day_number: ''
      },
      orderNumbers: [],
      queryOrderNumbers: [],
      orderNumberQuery: '',
      student_finish: false,
			student_upload: false,
    }
  },
  mounted () {

  },
  computed: {
    sumDate() {
      let start = new Date(),
        now = new Date()
      if (Object.keys(this.orderData).length > 0) {
        start = this.orderData.pick_up_date ? this.orderData.pick_up_date : this.orderData.created_at
      }
      return intervalTime(start, now, true).split('天')[0]
    },
    teacher_upload () {
      if (this.orderData) {
        let sta = this.orderData.statuss
        let teacher = this.$store.state.user.is_teacher

        if (teacher == 1) {
          // 如果是导师分配案件 并且 是发明人退回的案件 导师就可以上传撰写文件
          if (!this.orderData.student_id) { // 自己的案件
            return true
          } else { // 分配案件
            // 判断是不是退回
            if (this.orderData.student_id != '' && sta[0].id == 15) {
              return true
            } else {
              return false
            }
          }

        } else if (teacher == 2) {
          // 如果是导师分配案件 并且 是审核员驳回的案件则徒弟不能撰写
          if (this.orderData.student_id != '' && (sta[0].id == 5 || sta[0].id == 15)) {
            return false
          } else {
            return true
          }
        }
      }
      return true
    },
    canAllocationOrder () {
      if (this.orderData) {
        if (this.orderData.student_id) {
          return true
        } else {
          return false
        }
      } else {
        return false
      }
    },
  },
  watch: {
    orderData: {
      handler: function (val) {
        if (this.$store.state.user.is_teacher != 2) {
          this.student_finish = true
        } else {
          this.student_finish = false
          if (val.statuss) {
            if (val.statuss.findIndex(v => v.id == 5) > -1) {
              let statuss = val.statuss.slice(0, val.statuss.findIndex(v => v.id == 5))
              if (statuss.findIndex(v => v.id == 16) > -1) {
                if (statuss.findIndex(v => v.id == 17) > -1) {
                  this.student_finish = true
                  return this.student_upload = false
                }
                if (statuss.findIndex(v => v.id == 17) == -1 && statuss.findIndex(v => v.id == 18) == -1 && statuss.findIndex(v => v.id == 16) > -1) {
                  return this.student_upload = true
                }
                if (statuss.findIndex(v => v.id == 18) > statuss.findIndex(v => v.id == 16)) {
                  return this.student_upload = true
                }
              }
              if (val.statuss.findIndex(v => v.id == 5) < val.statuss.findIndex(v => v.id == 3)) {
                return this.student_upload = false
              }
            } else {
              if (val.statuss.findIndex(v => v.id == 17) > -1) {
                this.student_finish = true
                return this.student_upload = false
              }
              if (val.statuss.findIndex(v => v.id == 17) == -1 && val.statuss.findIndex(v => v.id == 18) == -1 && val.statuss.findIndex(v => v.id == 16) > -1) {
                return this.student_upload = true
              }
              if (val.statuss.findIndex(v => v.id == 18) > val.statuss.findIndex(v => v.id == 16)) {
                return this.student_upload = true
              }
            }
          }
        }
      },
      // immediate: true,
      deep: true
    }
  },
  methods: {

    show (data) {
      this.order_id = data.id
      this.getInfo()
      this.isShow = true
    },
    getInfo() {
      let params = {
        order: this.order_id
      }
      this.$axios.get(`api/order/${this.order_id}`, {params: params}).then (res => {
        if (res.data.code == 200) {
          this.interceptFile(res.data.data)
          this.orderData = res.data.data
          this.showProcess(this.orderData)
        }
      })
    },
    interceptFile (data) {
      //图片 切分组件
      if (data.thumb_imgs == null || data.thumb_imgs == "") {} else {
        let img_Arr = data.thumb_imgs.split("&");
        let img_Arr2 = data.img.split('&')
        data.imgArr = [];
        data.imgList = [];
        data.imgList2 = []
        for (const i in img_Arr2) {
          data.imgList2.push(global.baseurl + '/storage/upload/' + img_Arr2[i])
        }
        for (const i in img_Arr) {
          let itemobj = {
            id: i + 1,
            path: img_Arr[i],
            file: ''
          };
          data.imgList.push(global.baseurl + '/storage/upload/' + img_Arr[i])
          let itemArr = itemobj.path.split("/")
          itemobj.path = itemArr[itemArr.length - 1]
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.imgArr.push(itemobj);
        }
      }
      //文件 切分组件
      if (data.file == null || data.file == "") {} else {
        let file_Arr = data.file.split("&");
        data.fileArr = [];
        for (const i in file_Arr) {
          let itemobj = {
              id: i + 1,
              path: file_Arr[i],
              file: ''
          };
          let itemArr = itemobj.path.split("/")
          itemobj.path = itemArr[itemArr.length - 1]
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.fileArr.push(itemobj);
        }
      }
      // 导师审核文件
      if (data.student_review_file == null || data.student_review_file == "") {} else {
        let file_Arr = data.student_review_file.split("&");
        data.studentFile = [];
        for (const i in file_Arr) {
          let itemobj = {
              id: i + 1,
              path: file_Arr[i],
              file: ''
          };
          let itemArr = itemobj.path.split("/")
          itemobj.path = itemArr[itemArr.length - 1]
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.studentFile.push(itemobj);
        }
      }
      //已完成文件 切分组件
      if (data.fish_file == null || data.fish_file == "") {} else {
        let fishfileArr = data.fish_file.split("&");
        data.fishfileArr = [];
        for (const i in fishfileArr) {
          let itemobj = {
            id: i + 1,
            path: fishfileArr[i],
            file: ''
          };
          let itemArr = itemobj.path.split("/")
          itemobj.path = itemArr[itemArr.length - 1]
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.fishfileArr.push(itemobj);
        }
      }
      // 审核文件切分成数组
      if (data.review_file == null || data.review_file == "") {} else {
        let fileArr = data.review_file.split("&");
        data.reviewfileArr = [];
        for (const i in fileArr) {
          let itemobj = {
            id: i + 1,
            path: fileArr[i],
            file: ''
          };
          let itemArr = itemobj.path.split("/")
          itemobj.path = itemArr[itemArr.length - 1]
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.reviewfileArr.push(itemobj);
        }
      }
      // 撤案申请文件
      if (data.reason_file == null || data.reason_file == "") {} else {
        let reasonfileArr = data.reason_file.split("&");
        data.reasonfileArr = [];
        for (const i in reasonfileArr) {
          let itemobj = {
            id: i + 1,
            path: reasonfileArr[i],
            file: ''
          };
          let itemArr = itemobj.path.split("/")
          itemobj.path = itemArr[itemArr.length - 1]
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.reasonfileArr.push(itemobj);
        }
      }
      // 定稿文件
      if (data.confirm_file == null || data.confirm_file == "") {} else {
        let confimFiles = data.confirm_file.split("&");
        data.confimFiles = [];
        for (const i in confimFiles) {
          let itemobj = {
            id: i + 1,
            path: confimFiles[i],
            file: ''
          };
          let itemArr = itemobj.path.split("/")
          itemobj.path = itemArr[itemArr.length - 1]
          itemobj.file = itemArr.slice(0, 2).join("/");
          data.confimFiles.push(itemobj);
        }
      }
    },
    refresh(data) {
      this.$emit("refresh");
      this.isShow = false
    },
    intervalTime(startTime,endTime){
      var date1 = new Date(startTime); //开始时间
      var date2 = new Date(endTime); //结束时间
      var date3 = date2.getTime() - date1.getTime(); //时间差的毫秒数
      //计算出相差天数
      var days = (date3 / (24 * 3600 * 1000)).toFixed(1)
      //计算出小时数

      var leave1 = date3 % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
      var hours = (leave1 / (3600 * 1000)).toFixed(1)
      //计算相差分钟数
      var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
      var minutes = (leave2 / (60 * 1000)).toFixed(1)

      //计算相差秒数

      var leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
      var seconds = Math.round(leave3 / 1000);
      // return days + "天 " + hours + "小时 " + minutes + "分钟" + seconds + " 秒";

      if (days > 0) {
        return days + '天'
      } else {
        if (hours > 0) {
          return hours + "小时"
        } else {
          return minutes + "分钟"
        }
      }
      // return days + "天"
    },
    showProcess (row) {
      
      let list = row.statuss.map(item => item.id)

      if (list.includes(8)) {
        this.opDateMax = 8
        return
      }
      if (list.includes(28)) {
        this.opDateMax = 6
        return
      }
      if (list.includes(7)) {
        this.opDateMax = 7
        return
      }
      // if (list.includes()) {
      //   this.opDateMax = 7
      //   return
      // }
      if (list.includes(13 || 29)) {
        this.opDateMax = 6
        return
      }
      if (list.includes(15)) {
        this.opDateMax = 2
        return
      }
      if (list.includes(10)) {
        this.opDateMax = 5
        return
      }
      if (list.includes(4)) {
        this.opDateMax = 4
        return
      }
      if (list.includes(5)) {
        this.opDateMax = 2
        return
      }
      if (list.includes(3)) {
        this.opDateMax = 3
        return
      }
      
      if (list.includes(2)) {
        this.opDateMax = 2
        return
      }
      if (list.includes(1)) {
        this.opDateMax = 1
        return
      }
      
    },
    finalizeChange(file, fileList){
      let tempList = [];//可以上传的文件
      for(let i = 0;i<fileList.length;i ++){
        let canUpload = true;//是否可以上传
        let that = this;
        //验证文件类型
        let fileName = fileList[i].name;
        //文件切成数组 然后去判断格式
        let fileNameArr =  fileName.substring(that.orderData.order_number.length + 1).split("-");
        let arrLen = fileName.split("-").length;
        let orderNum = fileName.substr(0, that.orderData.order_number.length);
        //获取后缀名 必须是文档格式
        let pos = fileName.lastIndexOf(".");
        let lastName = fileName.substring(pos, fileName.length);
        if (
          // lastName.toLowerCase() !== ".doc" &&
          lastName.toLowerCase() !== ".docx"
        ) {
          that.$message.error("文件必须为.docx格式");
          canUpload = false;
        } else if (fileNameArr.length != 3) {
          that.$message.error('请按照格式：(订单编号-代理人-案件名称-专利类型.docx),修改文件名后重新上传')
          canUpload = false;
        } else if (orderNum != that.orderData.order_number) {
          that.$message.error("文件名中订单编号与订单不符合，请修改后重新上传");
          canUpload = false;
        } else if (fileNameArr[0] != that.orderData.agent.name) {
          that.$message.error("代理人姓名不一致");
          canUpload = false;
        } else if (!/^(发明专利|实用新型|外观设计)$/.test(fileNameArr[fileNameArr.length-1].split(".")[0])) {
          that.$message.error("案件类型必须是【发明专利, 实用新型, 外观设计】中的一种");
          canUpload = false;
        }
        if(canUpload){
          tempList.push(fileList[i]);
        }
      }

      this.fileListV.splice(0,this.fileListV.length,...tempList);
      for(let i = 0; i < this.fileListV.length; i++) {
        let nowTime = moment().format('YYYY-MM-DD HH:mm:ss')
        this.$set(this.fileListV[i],'close', false)
        this.$set(this.fileListV[i],'time', nowTime)
      }
      fileList.splice(0,fileList.length,...tempList);
      return ;
    },
    auditChange(file, fileList) {
      let tempList = [];//可以上传的文件
      for(let i = 0;i<fileList.length;i ++){
        let canUpload = true;//是否可以上传
        let that = this;
        //验证文件类型
        let fileName = fileList[i].name;
        //文件切成数组 然后去判断格式
        let fileNameArr = fileName.substring(that.orderData.order_number.length + 1).split("-");
        let arrLen = fileName.split("-").length;
        //1.获取后缀名 必须是文档格式(doc/docx)
        let pos = fileName.lastIndexOf(".");
        let lastName = fileName.substring(pos, fileName.length);
        let orderNum = fileName.substr(0, that.orderData.order_number.length);
        let typeArr = ['发明专利', '实用新型', '外观设计'] // 专利类型
        if (
          // lastName.toLowerCase() !== ".doc" &&
          lastName.toLowerCase() !== ".docx"
        ) {
          that.$message.error("文件必须为.docx格式");
          canUpload = false;
          //2.拼接订单编号 判断编号是否一致
        }else if (orderNum != that.orderData.order_number) {
          that.$message.error("文件名中订单编号与订单不符合，请修改后重新上传");
          canUpload = false;
        }else if (that.orderData.status == "代理人撰写中") {
          if (fileNameArr.length != 3 && fileNameArr.length != 4) {
            that.$message.error('文件名格式不正确')
            canUpload = false;
          } else {
            let type_name = ''
            if (fileNameArr.length == 3) {
              type_name = fileNameArr[2]
            } else if (fileNameArr.length == 4) {
              type_name = fileNameArr[3]
            }
            if (fileNameArr[0] != that.orderData.agent.name  && fileNameArr[1] != that.orderData.agent.name) {
              that.$message.error("代理人姓名不一致");
              canUpload = false;
            }
            if (!/^(发明专利|实用新型|外观设计)$/.test(type_name.split(".")[0])) {
              that.$message.error("案件类型必须是【发明专利, 实用新型, 外观设计】中的一种");
              canUpload = false;
            }
            if(fileNameArr.length == 5){
              if (!(/^[0-9]{0,}$/.test(fileNameArr[0]))) {//序号
                that.$message.error("多报格式为订单编号后加'-数字'");
                canUpload = false;
              }
            }
          }
        }else if (that.orderData.status == "案件修改中") {
          if (fileNameArr.length != 4 && fileNameArr.length != 5) {
            that.$message.error('文件名格式不正确')
            canUpload = false;
          }else{
            if (!(/^R[0-9]{0,}$/.test(fileNameArr[fileNameArr.length - 1].split('.')[0]))) {//R号
              that.$message.error("文件名格式不正确");
              canUpload = false;
            }
            let type_name = ''
            if (fileNameArr.length == 4) {
              type_name = fileNameArr[2]
            } else if (fileNameArr.length == 5) {
              type_name = fileNameArr[3]
            }
            if (fileNameArr[0] != that.orderData.agent.name  && fileNameArr[1] != that.orderData.agent.name) {
              that.$message.error("代理人姓名不一致");
              canUpload = false;
            }
            if (!/^(发明专利|实用新型|外观设计)$/.test(type_name.split(".")[0])) {
              that.$message.error("案件类型必须是【发明专利, 实用新型, 外观设计】中的一种");
              canUpload = false;
            }
            if(fileNameArr.length == 5){
              if (!(/^[0-9]{0,}$/.test(fileNameArr[0]))) {//序号
                that.$message.error("多报格式为订单编号后加'-数字'");
                canUpload = false;
              }
            }
          }
        }
        if(canUpload){
          tempList.push(fileList[i]);
        }
      }
      this.fileListV.splice(0,this.fileListV.length,...tempList);
      for(let i = 0; i < this.fileListV.length; i++) {
        let nowTime = moment().format('YYYY-MM-DD HH:mm:ss')
        this.$set(this.fileListV[i],'close', false)
        this.$set(this.fileListV[i],'time', nowTime)
      }
      fileList.splice(0,fileList.length,...tempList);
      return ;
    },
    //完成文件
    handleChangeByok(file, fileList) {
      let tempList = [];//可以上传的文件
      for(let i = 0;i<fileList.length;i ++){
        let canUpload = true;//是否可以上传
        let that = this;
        //验证文件类型
        let fileName = fileList[i].name;
        //文件切成数组 然后去判断格式
        let fileNameArr = fileName.substring(this.orderData.order_number.length + 1).split("-");
        let arrLen = fileName.split("-").length;
        let orderNum = fileName.substr(0, this.orderData.order_number.length); // 上传文件订单编号
        //获取后缀名 必须是压缩文件(zip/rar)
        if(orderNum != this.orderData.order_number){
          that.$message.error("文件名的订单编号不正确");
          canUpload = false;
        }else if(fileNameArr[0] == this.orderData.agent.name){
          that.$message.error("发明人姓名不正确");
          canUpload = false;
        }else if(fileName.split(".")[1] !== "zip" && fileName.split(".")[1] !== "rar"){
          that.$message.error("文件必须为压缩包格式");
          canUpload = false;
        }else if(!/^(发明专利|实用新型|外观设计)$/.test(fileNameArr[fileNameArr.length-1].split(".")[0])){
          that.$message.error("专利类型必须是【发明专利, 实用新型, 外观设计】中的一种");
          canUpload = false;
        }else if (fileNameArr.length != 3) {
          that.$message.error(
            "请按照格式：(编号-姓名(发明人)-案件名称-专利类型.rar/zip),修改文件名后重新上传"
          )
          canUpload = false;
        }
        if(canUpload){
          tempList.push(fileList[i]);
        }
      }
      this.fileListV.splice(0,this.fileListV.length,...tempList)
      for(let i = 0; i < this.fileListV.length; i++) {
        let nowTime = moment().format('YYYY-MM-DD HH:mm:ss')
        this.$set(this.fileListV[i],'time', nowTime)
        this.$set(this.fileListV[i],'isBeyond', false)
        this.$set(this.fileListV[i],'claimValue', 0)
        this.$set(this.fileListV[i],'close', false)
      }
      fileList.splice(0,fileList.length,...tempList);
      return ;
    },
    handleRemove(file, fileList) {
      this.fileListV = fileList;
    },
    //发送定稿提交
    submitUploadDG() {
      if (this.fileListV == 0) {
        this.$message({
          type: "warning",
          message: "请选择需要上传的文件！"
        });
        return
      }
      this.fileBtnLoading = true
      // FormData 对象
      var form = new FormData();
      // 文件对象
      for (let i in this.fileListV) {
        form.append(i==0?"file":("file"+(i*1+1)), this.fileListV[i].raw);
      }
      form.append("order", this.orderData.id);
      axios({
        method: "post",
        url: this.baseUrl + "/api/order/" + this.orderData.id + "/send/file",
        data: form,
        headers: {
          "Content-Type": "multipart/form-data",
          Authorization: "Bearer " + this.$store.state.token
        }
      })
      .then(res=>{
        if(res.data.code == 200){
          this.fileList = [];
          this.fileListV = [];
          this.$message({
            type: "success",
            message: "发送成功",
            duration: 2000
          });
          this.$emit("refresh");
          this.fileBtnLoading = false
          this.isShow = false
        } else{
          this.fileBtnLoading = false
          this.isShowEmailPwd = true;
        }
      })
    },
    handleCloseEmail() {
      this.emailPwd = ''
      this.isShowEmailPwd = false;
    
    },
    emailPwdFn() {
      if (this.emailPwd == "") {
        this.$message.error("发送邮件密码不能为空");
        return;
      }
      let obj = {
        pwd: this.emailPwd
      };
      this.$axios
        .post("api/consumer/set/emailpwd", obj)
        .then(({
          data
        }) => {
          if (data.status == "success") {
            //this.$message.success("设置成功");
            //将密码存入cookie
            let userObj = this.$store.state.user;
            userObj.email_pwd = this.emailPwd;

            //修改后先清空cookie
            this.$store.commit("delUser");
            this.$cookies.remove("user");

            this.$cookies.set("user", aes.Encrypt(JSON.stringify(userObj)));
            this.$store.commit("setUser", userObj);

            this.isShowEmailPwd = false;
            this.submitUploadDG();
          } else {
            this.$message.error("设置失败" + data.message);
          }
        })
        .catch(err => {
          this.$message.error(err);
        });
    },
    // 代理人上传内审文件
    submitUpload(type = false) {
      if (this.fileListV == 0) {
        this.$message({
          type: "warning",
          message: "请选择需要上传的文件！"
        });
        return
      }
      // FormData 对象
      var form = new FormData();
      // 免审文件数据处理
      if (type) {
        let free_check = []
        this.fileListV.forEach(v => {
          free_check.push(v.name)
        })
        form.append("free_check", free_check)
      }

      // 文件对象
      for (let i in this.fileListV) {
        form.append(i==0?"file":("file"+(i*1+1)), this.fileListV[i].raw);
      }
      let url = this.baseUrl + "/api/order/" + this.orderData.id + "/upload"
      if (this.$store.state.user.is_teacher == 2 && !this.student_finish) {
        url =  this.baseUrl + "/api/order/" + this.orderData.id + "/student_upload"
      }
      form.append("order", this.orderData.id);
      if (type) {
        this.$confirm('确认上传免审文件吗', '提示', {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          center: true,
          type: 'warning'
        }).then(() => {
          this.sumbitPost(url, form)
        }).catch(e => {})
      } else {
        this.sumbitPost(url, form)
      }
    },
    sumbitPost(url, form) {
      this.fileBtnLoading = true
      axios({
        method: "post",
        url: url,
        data: form,
        headers: {
          "Content-Type": "multipart/form-data",
          Authorization: "Bearer " + this.$store.state.token
        }
      }).then(res => {
        if (res.data.status == "success") {
          this.fileBtnLoading = false
          this.$message({
            type: "success",
            message: "上传成功"
          });
          this.handleClose();
          this.$emit('refresh')
        } else {
          this.$message({
            type: "error",
            message: res.data.message
          });
          this.fileListV=[];
          this.fileList=[];
        }
      }).catch (err => {
        this.fileBtnLoading = false
        console.log(err)
      })
    },
    uploadSectionFileByok() {
      if (this.fileListV == 0) {
        this.$message({
          type: "warning",
          message: "请选择需要上传的文件！"
        });
        return
      }
      this.completeFilePost()
    },
    completeFilePost(args) {
      this.fileBtnLoading = true
				// FormData 对象
      var form = new FormData();
      // 文件对象
      for (let i in this.fileListV) {
        form.append(i==0?"file":("file"+(i*1+1)), this.fileListV[i].raw);
      }
      form.append("order", this.orderData.id);
      if (this.sameDay.isSameDay) {
        let sameDayNumbers = []
        for(let i = 0; i < this.orderNumbers.length; i++) {
          if (this.orderNumbers[i].isSelect) {
            sameDayNumbers.push(this.orderNumbers[i].value)
          }
        }
        let same_day_number = sameDayNumbers.join(",")
        form.append('same_day_number', same_day_number)
      }
      let claimArr = []
      let claim_item = ''
      for(let i = 0; i < this.fileListV.length; i++) {
        claimArr.push(this.fileListV[i].claimValue)
      }
      claim_item = claimArr.join(",")
      form.append('claim_item', claim_item)

      let url = null
      if (this.orderData.is_distribution == 3) {
        url =  `/api/order/${this.orderData.id}/agent/order/confirm/file`
      } else {
        url = `/api/order/${this.orderData.id}/upload/confirm/file`
      }
      axios({
        method: "post",
        url: this.baseUrl + url,
        data: form,
        headers: {
          "Content-Type": "multipart/form-data",
          Authorization: "Bearer " + this.$store.state.token
        }
      }).then(res => {
        if (res.data.status == "success") {
          this.$message({
            type: "success",
            message: "上传成功"
          });
          // this.dialogVisible = false;
          this.fileBtnLoading = false
          this.handleClose()
          this.$emit('refresh')
        } else {
          this.fileBtnLoading = false
          this.$message({
            type: "error",
            message: res.data.message
          });
        }
      });
    },
    fileListHidClose (item) {
      item.close = false
    },
    fileListShowClose (item) {
      item.close = true
    },
    closeFileList(item,index) {
      this.fileListV.splice(index, 1)
      this.$refs['upload'][0].uploadFiles.splice(index, 1)
    },
    uploadSectionFile(params) {
    },
    // 查询同日提交案件编号
    queryChanged (value) {
      let data = this.queryOrderNumbers.filter( item => {
        return item.value.search(value) > -1
      })
      this.orderNumbers = data
    },
    // 删除同日提交订单编号
    closeOrderNumber(item, index) {
      this.orderNumbers[index].isSelect = false
    },
    // 获取可同日提交案件
    sameDayCheckChange(value) {
      if (value) {
        let params = {
          order_number:this.orderData.order_number
        }
        this.$axios.get('api/order/agent/list', {params: params}).then(res => {
          if (res.data.code == 200){
            let data = res.data.data
            for(let i = 0; i < data.length; i++) {
              let item = {
                value: data[i],
                index: i,
                isSelect: false,
                close: false
              }
              this.orderNumbers.push(item)
              this.queryOrderNumbers = this.orderNumbers
            }
          }
        })
      } else {
        this.orderNumbers = []
        this.sameDay.same_day_number = ''
      }
    },
    handleClose() {
      this.student_upload = false
			this.student_finish = false
      this.fileList = [];
      this.fileListV = [];
      this.fileListByok = [];
      this.orderNumbers = []
      this.sameDay = {
        isSameDay: false,
        same_day_number: ''
      }
      this.orderNumberQuery = ''
      this.isShow = false
    },
    rescind(data) {
      this.orderData.reason = data.reason
      this.orderData.reason_file = data.reason_file
      let reasonfileArr = data.reason_file.split("&");
      this.orderData.reasonfileArr = [];
      for (const i in reasonfileArr) {
        let itemobj = {
          id: i + 1,
          path: reasonfileArr[i],
          file: ''
        };
        let itemArr = itemobj.path.split("/")
        itemobj.path = itemArr[itemArr.length - 1]
        itemobj.file = itemArr.slice(0, 2).join("/");
        this.orderData.reasonfileArr.push(itemobj);
      }
      this.refresh()
    },
    orderRescind() {
      this.$refs['order-rescind'].showOn(this.orderData)
    },
    resetFile() {
      this.$refs['file-recind'].showOn(this.orderData)
    },
    goPay(){
      this.$router.replace({
        name: 'payment',
        query: {
          order_id: this.orderData.id,
          order: this.orderData.id,
          from: this.$route.path
        }
      })
    },
    // 导师分配代理人
    distributeOrder(data) {
      this.$refs['distributeOrder'].show(data)
    },
    auditorOrder(val) {
      this.$refs['studentOrder'].show(val)
    },
  }
}
</script>

<style lang='less' scoped>
  .order-info {
    &_title {
      text-align: center;
      font-size:20px;
      font-weight:bold;
      color:rgba(53,53,53,1);
      margin-bottom: 20px;
    }
    /deep/.el-dialog {
      width: 70%;
      min-width: 1000px;
      .el-dialog__close {
        font-size: 20px;
      }
      .el-dialog__body {
        padding-top: 10px;
      }
    }
    .el-form-item__content {
      text-align: center;
      font-size:20px;
      font-weight:bold;
      color:rgba(53,53,53,1);
      margin-bottom: 20px;
    }
    /deep/.form {
      .el-form-item {
        height: 100%;
        border: 1px solid #ccc;
        margin-right: -1px;
        margin-bottom: -1px;
        // border-bottom-width: 0;
        .el-form-item__label {
          // background:rgba(194,227,255,1);
          text-align: left;
          font-size:15px;
          color:#555555;
          padding-left: 20px;
        }
        .el-form-item__content{
          // background:rgba(244,247,255,1);
          padding-left: 20px;
          text-align: left;
          color:#555555;
        }
      }
      .el-row {
        .el-col-12 {
          .el-form-item {
            border-bottom-width: 0;
          }
        }
        .el-col-24 {
          .el-form-item {
            border-bottom: 0px;
          }
        }
      }
      .el-row:last-child  {
        .el-col-12 {
          .el-form-item {
            border-bottom-width: 1px;
          }
        }
        .el-col-24 {
          .el-form-item {
            border-bottom: 1px solid #ccc;
          }
        }
      }
      .pre-img {
        margin-top: 8px;
      }
    }
    /deep/.el-steps {
      margin-top: 60px;
      margin-bottom: 20px;
      .el-step {
        .el-step__main{
          width: 100%;
          .el-step__title {
            text-align: center;
            font-size: 15px;
            width: 100%;
            line-height: 20px;
            font-size:15px;
            color:rgba(85,85,85,1);
          }
          .is-wait {
            color:rgba(181,181,181,1);

            .el-step__icon {
              
            }
            
          }
        }
        .is-wait {
          .el-step__icon  {
            .el-step__icon-inner {
              display: none;
            }
          }
        }
        
        .is-success {
          .el-step__line {
            background-color:  rgba(36,157,255,1);
          }
          .el-step__icon {
            background: rgba(36,157,255,1);
            color: #fff;
            border-color: rgba(36,157,255,1);
          }
        }

        
      }
      .el-step:nth-child(odd) {
        .el-step__main{
          position: absolute;
          top: -40px;
        }
      }
      .el-step:nth-child(even) {
        .el-step__main{
          margin-top: 15px;
        }
      }
			
			.el-steps--vertical {
				width: 420px;
				margin: 0 auto;
			}
			
    }
    /deep/.el-timeline {
      .el-timeline-item {
        padding-bottom: 10px;
        .el-timeline-item__tail {
          display: block;
          border-color: rgba(36,157,255,1);
          left: 120px;
        }
        .time {
          position: absolute;
          left: 0;
          font-size: 15px;
          min-width: 100px;
        }
        .title {
          font-size:15px;
          color:rgba(63,63,63,1);
          line-height: 40px;
          font-weight: 700;
        }
        .el-timeline-item__node {
          border:1px solid rgba(36,157,255,1);
          background: #fff;
          position: relative;  
          display: flex;
          left: 115px;
          width: 12px;
          height: 12px;
          border-radius: 50%;
          -webkit-box-pack: center;
          justify-content: center;
          -webkit-box-align: center;
          align-items: center;
        }
        .el-timeline-item__node::after {
          content: '';
          display: block;
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate( -50% , -50%);
          border-radius: 50%;

          width: 7px;
          height: 7px;
          background: rgba(36,157,255,1);
        }
        .el-timeline-item__wrapper {
          padding-left: 148px;
          .el-timeline-item__timestamp {
            margin-bottom: 15px;
          }
        }
        // .el-timeline-item__content {
        //   zoom: 1;
        // }
        // .el-timeline-item__content::after {
        //   content: "";
        //   display: block;
        //   height: 0;
        //   clear: both;
        //   visibility: hidden;
        // }
      }
    }
    /deep/.el-rate {
      margin-top: 9px;
      // height: 40px;
      // line-height: 40px;
    }
    // /deep/.el-timeline:last-child {
    //   .el-timeline-item {
    //     .el-timeline-item__tail {
    //       display: none;
    //     }
    //   }
    // }
    .fold {
      &_header {
        height: 40px;
        margin-bottom: 20px;
        line-height: 40px;
        font-size:15px;
        font-family:Source Han Sans CN;
        font-weight:300;
        color:rgba(199,199,199,1);
        border-bottom: 1px solid rgba(220,220,220,1);
        i {
          line-height: 1;
          font-size: 17px;
        }
      }
    }
    .file-list {
      &_item {
        color: #58A5EA;
        font-size: 15px;
        &_name {
          max-width: 200px;
          display: inline-block;
          line-height: 1;
          overflow:hidden;
          text-overflow:ellipsis;
          white-space:nowrap;
        }
        .file-list_item_checkbox {
          margin-left: 20px;
          display: inline-block;
        }
        .file-list_item_input {
          display: inline-block;
          width: 80px;
          margin-left: 20px;
        }
        .closeIcon {
          font-size: 18px;
          line-height: 1;
        }
      }
      .sameDay {
        width: 300px;
        display: inline-block;
        line-height: 1;
      }
      .numbers {
        color: #58A5EA;
        font-size: 15px;
        line-height: 30px;
        .numberItem {
          // border: 1px solid #ccc;
          width: 487px;
          display: inline-block;
        }
      }

    }
    /deep/.tips {
      .tips_1 {
        color: midnightblue;
        line-height: 20px;
      }

      .tips_2 {
        color: red;
        line-height: 20px;
      }

    }
  }
 

</style>